<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Search</title>
<LINK REL="stylesheet" HREF="CSS/Main.css" TYPE="text/css">
<LINK REL="stylesheet" HREF="CSS/Button.css" TYPE="text/css">
</head>
<body>

	<div id="top">
		<h1>Master Data Management</h1>
		<br> <a id="log" href="logout">Logout</a><br>
		<%@ include file="redirection.jsp"%>
		<div id="menu">
			<ul>
				<li>
					<form action="logout" method="post">
						<a><input type="submit" name="Logout" value="Logout"></a>
					</form>
				</li>
			</ul>
		</div>
	</div>
	<%
		String location = "";
		String currency = "";
		String commodity = "";
		String market = "";
		if (request.getAttribute("location") != null)
			location = (String) request.getAttribute("location");
		if (request.getAttribute("currency") != null)
			currency = (String) request.getAttribute("currency");
		if (request.getAttribute("commodity") != null)
			commodity = (String) request.getAttribute("commodity");
		if (request.getAttribute("market") != null)
			market = (String) request.getAttribute("market");
	%>
	<div id="left">
		<form action="SearchServlet" method="post">
			<h2>Search</h2>
			<div class="box">
				<Table>
					<tr>
						<td>Location:</td>
						<td><input type="text" name="Location" value="<%=location%>">
						</td>
					</tr>
					<tr>
						<td>Currency:</td>
						<td><input type="text" name="Currency" value="<%=currency%>">
						</td>
					</tr>
					<tr>
						<td>Market:</td>
						<td><input type="text" name="Market" value="<%=market%>">
						</td>
					</tr>
					<tr>
						<td>Commodity:</td>
						<td><input type="text" name="Commodity"
							value="<%=commodity%>"></td>
					</tr>
				</Table>

				<input type="submit" class="button" name="Search" value="Search">
			</div>

		</form>
		<div class="visbox">
			<%
				if (session.getAttribute("role").equals("admin")) {
			%>
			<form action="Home.jsp">
				<input type="submit" class="button" name="Home" value="Home">
			</form>
			<%
				} else {
			%>
			<form action="HomeUser.jsp">
				<input type="submit" class="button" name="Home" value="Home">
			</form>
			<%
				}
			%>
		</div>
	</div>
	<form>
		<div id="right">

			<%
				String[][] result = (String[][]) request.getAttribute("result");
				if (result != null) {
			%>
			<Table border="1" width="600">
				<tr>
					<td colspan="8">Commodity Info</td>
				</tr>
				<tr>
					<th>Market Name</th>
					<th>Commodity</th>
					<th>Currency</th>
					<th>Location</th>
					<th>Start Date</th>
					<th>End Date</th>
					<%	if(session.getAttribute("role").equals("admin")){ %>
						<th>Flag</th>
						<%} %>
					<th>Edit</th>
				</tr>
				<%
					for (String[] s : result) {
				%>
				<tr>
					<td><%=s[1]%></td>
					<td><%=s[2]%></td>
					<td><%=s[3]%></td>
					<td><%=s[4]%></td>
					<td><%=s[5]%></td>
					<td><%=s[6]%></td>
					<%	if(session.getAttribute("role").equals("admin")){
						String f = s[7];
								if (f.equals("Y")) {
					%>
					<td>Yes</td>
					<%
						} else {
					%>
					<td>No</td>
					<%
						}}
					%>
					<td><form action="SearchServlet" method="get">
							<input type="hidden" name="marketid" value="<%=s[0]%>"> <a><input
								type="submit" name="Edit" value="Edit"></a>
						</form></td>
				</tr>
				<%
					}
					}
				%>

			</Table>
		</div>
	</form>

</body>
</html>